Skip to content

gh-152030: Clarify sequence.index() signature#152092

Open
subscapularis wants to merge 10 commits into
python:mainfrom
subscapularis:patch-1
Open

gh-152030: Clarify sequence.index() signature#152092
subscapularis wants to merge 10 commits into
python:mainfrom
subscapularis:patch-1

Conversation

@subscapularis

@subscapularis subscapularis commented Jun 24, 2026

Copy link
Copy Markdown

Updated the method signature for sequence.index to use the positional-only marker (/), replacing the old bracket syntax.

Updated the method signature for sequence.index to use the positional-only marker (/), replacing the old bracket syntax. Fixes python#152030
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Jun 24, 2026
@python-cla-bot

python-cla-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@read-the-docs-community

read-the-docs-community Bot commented Jun 24, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33303377 | 📁 Comparing bcb1ee3 against main (ff781d5)

  🔍 Preview build  

7 files changed · ± 7 modified

± Modified

skirpichev
skirpichev previously approved these changes Jun 24, 2026

@skirpichev skirpichev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, as a fix for sphinx docs.

This will not fix the issue, however. Method signatures should be fixed too (at least for str/bytes.index(), maybe more).

@subscapularis

Copy link
Copy Markdown
Author

@skirpichev Thanks for the review on the docs. I went ahead and dug into the C code to fix the underlying signatures for these methods as well. Here is what I updated:

The C-Code: I updated the Argument Clinic [clinic input] blocks for the master find methods in Objects/unicodeobject.c, Objects/bytesobject.c, and Objects/bytearrayobject.c. I removed the hardcoded @text_signature overrides and properly mapped the c_default values for start and end.
The Cascade: Because methods like count, index, rfind, and rindex clone their signatures from find, this single fix cleanly cascades down to all of them across all three types.
The Test Suite: I updated Lib/test/test_inspect.py to remove these newly supported methods from the methods_unsupported_signature lists (including the typing.Text alias).

I compiled and ran the test suite locally. test_inspect now passes cleanly with 0 failures, and the bracket-free signatures generate perfectly across all types!

@skirpichev skirpichev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, probably you misinterpreted me. My suggestion was to make code changes in a separate pr.

But now, as signatures for count/find/etc were changed - please update sphinx docs too.

Comment thread Objects/bytearrayobject.c Outdated
@skirpichev

Copy link
Copy Markdown
Member

@subscapularis, please do not click the "Update branch" button without a good reason because it notifies everyone watching the PR that there are new changes, when there are not, and it uses up limited CI resources.

@subscapularis

subscapularis commented Jun 25, 2026

Copy link
Copy Markdown
Author

Ah my apologies for the 'Update branch' spam, didn't realize it pinged all the watchers

Since my initial docs fix, I ended up going down the rabbit hole to fix the underlying C-signatures as well. Since we are keeping it all in this PR, here is a complete summary of everything that has been updated:

  1. The C-Code & Argument Clinic
    Updated the [clinic input] blocks for the master find methods in Objects/unicodeobject.c, Objects/bytesobject.c, and Objects/bytearrayobject.c

Removed the hardcoded @text_signature overrides

Dropped the redundant accept and c_default parameters from the start arguments

Also as far as i know methods like count, index, rfind, and rindex clone from find so, this single fix cascaded cleanly to all of them across all three types

  1. The Test Suite
    Updated Lib/test/test_inspect.py to remove these newly supported methods from the methods_unsupported_signature lists (including the typing.Text alias). The test suite now fully passes locally

  2. The Sphinx Docs
    Updated Doc/library/stdtypes.rst to reflect the new bracket-free signatures for count, find, rfind, and rindex across str, bytes, and bytearray

Formatted them using the stacked multiple-signature layout with start=0 and stop=sys.maxsize as you suggested

I also just ran a global clinic.py --make sync to ensure all the hidden .c.h checksums are perfectly up to date for the CI bots

Thank you for being so patient and letting me keep all these fixes in one place, let me know if everything looks good to go

Comment thread Doc/library/stdtypes.rst Outdated
@skirpichev skirpichev self-requested a review June 25, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants